package gui;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JRadioButton;

public class Визуализатор_для_Скобок extends JFrame {
	
	public static final int minWidth = 400, minHeight = 300;
	
	public static Визуализатор_для_Скобок WorkFrame;
	public static TreeDrawingPanel WorkPanel;
	
	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void start() {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Визуализатор_для_Скобок frame = new Визуализатор_для_Скобок();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Визуализатор_для_Скобок frame = WorkFrame = new Визуализатор_для_Скобок();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Визуализатор_для_Скобок() {
		WorkFrame = this;
		
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, minWidth, minHeight);
		setMinimumSize(new Dimension(minWidth, minHeight));
		setTitle("Дерево скобочного выражения");
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		GridBagLayout gbl_contentPane = new GridBagLayout();
		gbl_contentPane.columnWidths = new int[] {30, 30, 30};
		gbl_contentPane.rowHeights = new int[] {30, 0, 30};
		gbl_contentPane.columnWeights = new double[]{0.0, 0.0, 1.0};
		gbl_contentPane.rowWeights = new double[]{0.0, 0.0, 1.0};
		contentPane.setLayout(gbl_contentPane);
		
		
		JComboBox<String> comboBox = new JComboBox<String>();
		comboBox.setEditable(true);
		
		//String b = null;
		comboBox.setActionCommand(Слушатель_Команд.attachTree);
		comboBox.addActionListener(Главное_Окно.listener);
		
		comboBox.setModel(new DefaultComboBoxModel(new String[] {" ", "((-x))) \\должна появиться ошибка", "-(((x)))", "a                 +              b               *                c", "(ad + (ad + ( ad + (cf + (-qw)))))", "a+b", "a+ b+c", "(a + b) * cc", "(a / b)+(c * d)+(axy - g)+( p * rrr)"}));
		
		GridBagConstraints gbc_comboBox = new GridBagConstraints();
		gbc_comboBox.gridwidth = 3;
		gbc_comboBox.insets = new Insets(0, 0, 5, 0);
		gbc_comboBox.fill = GridBagConstraints.HORIZONTAL;
		gbc_comboBox.gridx = 0;
		gbc_comboBox.gridy = 0;
		contentPane.add(comboBox, gbc_comboBox);
		
		
		JPanel panel = new TreeDrawingPanel(minWidth, minHeight, WorkFrame);
		WorkPanel = (TreeDrawingPanel) panel;
		GridBagConstraints gbc_panel = new GridBagConstraints();
		gbc_panel.gridwidth = 3;
		gbc_panel.fill = GridBagConstraints.BOTH;
		gbc_panel.gridx = 0;
		gbc_panel.gridy = 2;
		contentPane.add(panel, gbc_panel);
		
		//panel.attachTree(StringRebuilder.getTree((String) comboBox.getSelectedItem()));
	}

}
